//
//  WBEmoticonButton.swift
//  SainMicroblog
//
//  Created by chenxinju on 16/5/14.
//  Copyright © 2016年 chenxinju-a2. All rights reserved.
//

import UIKit

class WBEmoticonButton: UIButton {

   //拥有数组模型
    var emoticon: WBEmoticon? {
    
        didSet {
            if let png = emoticon?.png {
                //拼接图片路径
               let imageName = "\(emoticon!.package!)/\(png)"
                //print(imageName)
              self.setImage(UIImage(named: imageName), forState: UIControlState.Normal)
                
            }else {
              self.setImage(nil, forState: UIControlState.Normal)
            
            }
            
            if let emoji = emoticon?.emoji {
              //有cod的才是emoj
                
                self.setTitle(emoji, forState: UIControlState.Normal)
            }else {
            
                self.setTitle(nil, forState: UIControlState.Normal)
            }
        
        }
    
    }

}
